package com.itheima.Demo01.Tesk02.Test03;

public class class1 implements Comparable<class1> {
    private String name;
    private int age;
    private float salary;

    public class1() {
    }

    public class1(String name, int age, float salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public float getSalary() {
        return salary;
    }

    public void setSalary(float salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "class1{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }


    @Override
    public int compareTo(class1 o) {
        float v = this.salary - o.salary;
        float v1 = v == 0 ? this.age - o.age : v;
        if (v1 < 0) {
            return 1;
        } else if (v > 0) {
            return -1;
        } else {
            return 1;
        }
    }
}
